/**************************************************************
  > File Name: myopendir.c
  > Author: LuoLiang
  > Mail: 1204553475@qq.com 
  > Created Time: 2021年12月16日 星期四 13时52分09秒
 **************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>

#define PATTERN "/etc"

int main(int argc,char **argv)
{

	DIR *fps = NULL;
	struct dirent *dir;
	fps = opendir(PATTERN);	
	if (fps == NULL)
	{
		perror("opendir()");
		exit(1);
	}
	
	while ((dir = readdir(fps)) != NULL)
			puts(dir->d_name);

	closedir(fps);

    exit(0);
}
